package Car;

/**
 * @author chenjian
 * @version 1.0
 * @date 2025/3/20 19:59
 * @description
 */

/*
* 2.定义继承Auto的子类Car,并添加空调，CD等成员变量
*
*
*
*
* */
public class Car2 extends Auto{
    private  boolean kongtiao;//空调
    private  boolean CDplayer;//CD音乐播放器
    //无参构造
    public Car2() {
    }

    //满参构造


    public Car2(int tirecount, String color, double weight, boolean kongtiao, boolean CDplayer) {
        super(tirecount, color, weight);
        this.kongtiao = kongtiao;
        this.CDplayer = CDplayer;
    }

    public boolean isKongtiao() {
        return kongtiao;
    }

    public void setKongtiao(boolean kongtiao) {
        this.kongtiao = kongtiao;
    }

    public boolean isCDplayer() {
        return CDplayer;
    }

    public void setCDplayer(boolean CDplayer) {
        this.CDplayer = CDplayer;
    }

    //代码重写
    //加速
    @Override
    public void addspeed(double value){
        this.speed += value * 1.2; // 假设小汽车加速更快
        System.out.println("小汽车加速，当前速度: " + this.speed);
    }
    //减速
    @Override
    public void slowspeed(double value) {
        if (this.speed - value * 0.8 < 0) {
            this.speed = 0;
        } else {
            this.speed -= value * 0.8; // 假设小汽车减速更慢
        }
        System.out.println("小汽车减速，当前速度: " + this.speed);
    }

}
